package cn.felord.algorithms.sort;

import java.util.Comparator;

/**
 * @author Dax
 * @since 18:08  2018/7/14
 */
public class User implements Comparator<User> {

    private String name;
    private int age;

    public User() {
    }

    public User(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }


    @Override
    public int compare(User o1, User o2) {
        return o1.age-o2.age;
    }

    @Override
    public String toString() {
        return "{" +
                "name:" + name +
                ", age:" + age +
                '}';
    }
}
